/**
 * @file 079.所有子集.cc
 * @author snow-tyan (zziywang@163.com)
 * @brief {Life is too short to learn cpp.}
 * @version 0.1
 * @date 2021-11-20
 * 
 * @copyright Copyright (c) 2021
 * 
 */

#include <iostream>
#include <string>
#include <vector>
using namespace std;

template <class T>
void print(const T &t)
{
    typename T::const_iterator it = t.begin();
    for (; it != t.end(); ++it) {
        cout << *it << " ";
    }
    cout << endl;
}

class Solution
{
public:
    vector<vector<int>> subsets(vector<int> &nums)
    {
        backtracking(nums, 0);
        return res;
    }

private:
    vector<vector<int>> res;
    vector<int> path;
    void backtracking(vector<int> &nums, int startIdx)
    {
        res.emplace_back(path);
        for (int i = startIdx; i < nums.size(); ++i) {
            path.push_back(nums[i]);
            backtracking(nums, i + 1);
            path.pop_back();
        }
    }
};

int main()
{
    vector<int> nums = {1, 2, 3};
    auto res = Solution().subsets(nums);
    for (auto &r : res) {
        print(r);
    }

    return 0;
}